from django.db import models

# Create your models here.
class Poet(models.Model):
    SEX = ((1,'男'),(2,'女'),(3,'KONG'))
    DYNASTY = ((1,'唐'),(2,'宋'),(3,'元'))
    # t_poet<name, sex, dynasty>
    name = models.CharField(max_length=20)
    sex = models.IntegerField(choices=SEX, null=False)
    dynasty = models.IntegerField(choices=DYNASTY,null=False)

    class Meta:
        db_table = 't_poet'
    def __str__(self): 
        return self.name

class Poem(models.Model):
    title = models.CharField(max_length=100)
    content = models.CharField(max_length=1000)
    author = models.ForeignKey(Poet, on_delete=models.CASCADE,null=True)
    def __str__(self): 
        return self.title
    
    class Meta:
        db_table = 't_poem'